<?php

namespace App\Http\Services;

use App\Http\Model\User;

class FeedbackServices extends CommonServices
{
    private $user_model;

    public function __construct()
    {
        $this->user_model = new User();
    }

    /**
     * 问题反馈
     * @param $report_user_id
     * @param $report_type
     * @param $pics
     * @param $describe
     * @return bool
     */
    public function feedbackAdd($user_id, $content, $imgs)
    {
        $images = [];
        $imgs = array_unique(array_filter(explode(",", $imgs)));
        foreach($imgs as $val) {
            if(!empty($val)) {
                $uri_arr = parse_url($val);
                if(!empty($uri_arr['path'])){
                    $images[] = $uri_arr['path'];
                }
            }
        }
        $images = json_encode($images);

        $this->user_model->feedback_commit($user_id, $content, $images);
        return true;
    }
    /**
     * 反馈处理
     */
    public function feedbackUpdate($params)
    {
        $id = $params['id']; //反馈id
        $note = $params['note']; //备注
        $updatetime = time(); //更新时间
        $update['note'] = $note; 
        $update['update_time'] = $updatetime;
        $update['fe_status'] = 1; //1已处理0未处理
        $res = $this->user_model->feedback_update($update,$id);
        return $res;
    }

}
